import '../css/index.css';

function sum(...args) {
  return args.reduce((total, currentVal) => total + currentVal, 0);
}

// eslint-disable-next-line
console.log(sum(1, 1, 1, 1, 1, 1));

/*
  1. eslint不认识window、navigator全局变量
    解决：需要修改package.jsoneslintConfig配置
    "env": {
      "browser": true// 支持浏览器端全局变量
    }
  2. serviceworker必须运行在服务器上
  --> nodejs
  --> cnpm i serve -g -> serve -s build 启动服务器，将build目录下所有资源作为静态资源
*/

// 注册serviceworker
// 处理兼容性问题
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js')
      .then(() => {
        // eslint-disable-next-line
        console.log('注册成功~');
      }).catch(() => {
        // eslint-disable-next-line
        console.log('注册失败！');
      });
  });
}
